home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1987 February / Ahoy_Magazine_87-02_1987_Double_L.d64 / Digit Decomp. (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  365b  |  15 lines

  1. 0 rem << cd38-4 >>
  2. 1 rem commodares problem #34-3:
  3. 2 print"digit decomposition"
  4. 3 rem solution by
  5. 4 rem   donald pellegrini
  6. 5 rem
  7. 10 sum=0 : b=1e8 : flg=0
  8. 20 input n:if n>999999999 or n<0 or n-int(n)>0 then 20
  9. 30 if n<10 then print n;"=";n : goto 10
  10. 40 for j=1 to 9
  11. 50 c=int(n/b) : if c>0 then flg=1
  12. 60 if flg=1 then print c;:sum=sum+c:if j<9 then print"+";
  13. 70 n=n-c*b : b=b/10
  14. 80 next : print"=";sum : goto 10
  15.